/*
 * NumberConverter.java
 *
 * Created on April 16, 2007, 11:18 AM
 */

import java.beans.*;
import java.io.Serializable;

/**
 * @author Tian, Juan
 */
public class NumberConverter extends java.awt.TextField implements Serializable {
    
   
    private PropertyChangeSupport propertySupport;
    
    public NumberConverter() {
        propertySupport = new PropertyChangeSupport(this);
        setText("rate set to " + rate);
    }
    
    
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.addPropertyChangeListener(listener);
    }
    
    public void removePropertyChangeListener(PropertyChangeListener listener) {
        propertySupport.removePropertyChangeListener(listener);
    }

    /**
     * Holds value of property rate.
     */
    private float rate = 1.0f;

    /**
     * Getter for property rate.
     * @return Value of property rate.
     */
    public float getRate() {
        return this.rate;
    }

    /**
     * Setter for property rate.
     * @param rate New value of property rate.
     */
    public void setRate(float rate) {
        setText("rate set to " + rate);
        this.rate = rate;
    }

    /**
     * Holds value of property validNum.
     */
    private float validNum;

    /**
     * Getter for property validNum.
     * @return Value of property validNum.
     */
    public float getValidNum() {
        //validNum = new Float(this.getText()).floatValue();
        return this.validNum;
    }

    /**
     * Setter for property validNum.
     * @param validNum New value of property validNum.
     */
    public void setValidNum(float validNum) {
        float oldValidNum = this.validNum;
        this.validNum = validNum;
        propertySupport.firePropertyChange ("validNum", new Float (oldValidNum), new Float (validNum));
    }
    
    
    
    
}
